package com.phone.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.phone.dao.StoreDao;
import com.phone.entity.Product;
import com.phone.entity.Store;
@Repository
public class StoreDaoimpl implements StoreDao {
	@Autowired
    private SessionFactory sessionFactory;
	@Override
	public void addproduct(Product product) {
		this.sessionFactory.getCurrentSession().save(product);
	}

	@Override
	public List<Product> showproduct(int sid) {
		List<Product> product=null;
		String hql="from Product where sid=?";
		try {
			Query query=this.sessionFactory.getCurrentSession().createQuery(hql);
			query.setParameter(0,sid);
			product=query.list();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return product;
	}

	@Override
	public boolean upstore(Store store) {
		this.sessionFactory.getCurrentSession().update(store);
		return true;
	}

}
